<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>注册</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/admin-lte/2.4.2/css/AdminLTE.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/iCheck/1.0.2/skins/flat/blue.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

    <style>
        body.login-page .has-feedback .form-control {
            padding-left: 34px;
            padding-right: 10px;
        }
        body.login-page .form-control-feedback {
            left: 0;
        }

        .login-box input.form-control {
            height: 46px;
            padding: 10px 16px;
            line-height: 1.3333333;
        }
        .form-control-feedback {
            top: 6px;
        }
    </style>
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="#">django</a>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">注册</p>

        <form action="/backend/reg/" method="post">
            {% csrf_token %}
            <div class="form-group has-feedback">
{#                <input type="text" name="username" value="" class="form-control" placeholder="账号">#}
                {{ userform.username }}
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
                {% if error.username.0 %}
                <p class="help-block" style="color: red">*{{ error.username.0 }}</p>
                {% endif %}
            {% if username_error %}
                <p class="help-block" style="color: red">*{{ username_error }}</p>
                {% endif %}
            </div>
            <div class="form-group has-feedback">
                <div class="input-group">
                    <input type="text" name="captcha_1" id="captcha_1" class="form-control" placeholder="图形验证码">
                    <span class="glyphicon glyphicon-info-sign form-control-feedback" style="z-index: 999;"></span>
                    <span class="input-group-addon captcha-img next-captcha" style="padding: 0;">
                        <img src="{{ imgage_url }}" class="captcha" alt="captcha">
                        <input id="id_reg_captcha_0" name="captcha_0" type="hidden" value="{{ hashkey }}">
                    </span>


                </div>
            </div>
{% if error.captcha.0 %}
                    <p class="help-block" style="color: red">*{{ error.captcha.0 }}</p>
                    {% endif %}

{#            <div class="form-group has-feedback">#}
{#                <div class="input-group">#}
{#                    <input type="text" name="captcha" id="captcha" class="form-control" placeholder="手机验证码">#}
{#                    <span class="glyphicon glyphicon-envelope form-control-feedback" style="z-index: 999;"></span>#}
{#                    <span class="input-group-addon">#}
{#                        <button type="button" class="btn btn-link btn-block" id="get-captcha" style="padding-top: 0; padding-bottom: 0;">获取验证码</button>#}
{#                    </span>#}
{#                </div>#}
{#            </div>#}
            <div class="form-group has-feedback">
                {{ userform.password }}
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                {% if error.password.0 %}
                <p class="help-block" style="color: red">*{{ error.password.0 }}</p>
                {% endif %}
            </div>
            <div class="form-group has-feedback">
                {{ userform.email }}
               <span class="glyphicon glyphicon-envelope form-control-feedback" style="z-index: 999;"></span>
                {% if error.email.0 %}
                <p class="help-block" style="color: red">*{{ error.email.0 }}</p>
                {% endif %}
            </div>
            <div class="form-group form-help-block">
                <div class="row">
                    <div class="col-xs-4">

                    </div>
                    <!-- /.col -->
                    <div class="col-xs-8 text-right">
                        已有账号？<a href="" class="text-center">立即登陆</a>
                    </div>
                    <!-- /.col -->
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <button type="submit" class="btn btn-primary btn-block btn-flat btn-lg">立即注册</button>
                </div>
                <!-- /.col -->
            </div>
        </form>

    </div>
    <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<!-- jQuery 3 -->
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="https://cdn.bootcss.com/iCheck/1.0.2/icheck.min.js"></script>
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_flat-blue',
            radioClass: 'iradio_flat-blue',
            increaseArea: '20%' // optional
        });
        $(".next-captcha").click(function(){
            $.getJSON("{% url 'backend:refresh-captcha' %}", function(json) {
                // This should update your captcha image src and captcha hidden input
                // debugger;
                var status = json['status'];
                var new_cptch_key = json['new_cptch_key'];
                var new_cptch_image = json['new_cptch_image'];
                id_captcha_0 = $("#id_reg_captcha_0");
                img = $(".captcha");
                id_captcha_0.attr("value", new_cptch_key);
                img.attr("src", new_cptch_image);
            });

        });
    });
</script>
</body>
</html>